﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WordRacer.Domain.Model.Dictionaries
{
  public class DictionaryWordComparer : IEqualityComparer<string>
  {
    public bool Equals(string s1, string s2)
    {
      if (s1.Length < s2.Length)
      {
        return s1.Equals(s2.Substring(0, s1.Length));
      }
      if (s2.Length < s1.Length)
      {
        return s2.Equals(s1.Substring(0, s2.Length));
      }
      if (s1.Length == s2.Length)
      {
        return s1.Equals(s2);
      }
      return false;
    }

    public int GetHashCode(string obj)
    {
      return obj.GetHashCode();
    }
  }
}
